const querystring = require("querystring")
module.exports = (req, res, next) => {
    if (req.headers["content-type"] === "application/x-www-form-urlencoded") {
        // 自己解析消息体
        let result = "";
        req.on("data", (chunk) => {
            result += chunk.toString("utf-8")
        })
        req.on("end", () => {
            const query = querystring.parse(result)
            req.body = query;
            next()
        })
    } else {
        next()
    }
}